// KSDDB.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "database.h"
#include "reachIndex.h"
#include "tupleSetGraph.h"
#include "initialize.h"
#include "query.h"
#define FIRST_USE 0

vector<database*> mydbs;
vector<reachIndex*> myReachIndexs;
tupleSetGraph myGlobalTSG;

void globalInitiate()
{

    initialize initInstance;
	initInstance.getConfFromFile();
    cout<<"Finish:get config!!!"<<endl;
	myGlobalTSG.constructSchema();
    cout<<"Finish:construct schema!!!"<<endl;
	if(FIRST_USE)
	{
 	   	initInstance.initialReachIndex();
  	   	cout<<"Finish:create ReachIndex!!!"<<endl;

		initInstance.initialKRIndex();
		cout<<"Finish:create KRIndex!!!"<<endl;
	}
}

void displayResult(map<double,sqlQueryResult> *result)
{
    map<double,sqlQueryResult>::iterator rItr=result->begin();
    int i,resultNo=1;
    while (rItr!=result->end())
    {
        cout<<"No:"<<resultNo<<"    Score:"<<(*rItr).first<<endl;
        cout<<"     ";
        for (i=0;i<(*rItr).second.tuple.size();i++)
        {
            cout<<"||"<<(*rItr).second.tuple[i];   
        }
        cout<<endl;
    }
}

int main(int argc, char* argv[])
{
	globalInitiate();
	while(1)
	{
		int num;
		cout<<"Please put in the num of keywords:"<<endl;
		//cin>>num;
        num=2;
		cout<<"Put in the keywords(with the space divided):"<<endl;
		vector<string> queryKeywords;
		string keyword;
		/*while (num--)
		{
           cin>>keyword;
			queryKeywords.push_back(keyword);
		}*/
        queryKeywords.push_back("regular");
        queryKeywords.push_back("package");
		query qq(queryKeywords,10);
	    qq.processQuery();
    //    displayResult(&(qq.mResult));
        system("pause");
	}
    return 0;
}











































